package com.cn.mobileproject.view.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cn.mobileproject.R;
import com.cn.mobileproject.bean.TaskDiscuss;
import com.cn.mobileproject.bean.TaskFeedback;
import com.cn.mobileproject.utils.TextHelper;

public class TaskDiscussAdapter extends BaseAdapter{
		
		Context mContext;
		private List<TaskDiscuss> mList;
		
		public TaskDiscussAdapter(Context context){
			mContext = context;
		}
		
		public List<TaskDiscuss> getList() {
			return mList;
		}

		public void setList(List<TaskDiscuss> mList) {
			this.mList = mList;
		}

		@Override
		public int getCount() {
			if(mList==null)	return 0;
			return mList.size();
		}

		@Override
		public Object getItem(int position) {
			return null;
		}

		@Override
		public long getItemId(int position) {
			return 0;
		}
		
		class HolderView {
			TextView contentView;
			TextView nameTextView;
			TextView timeTextView;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			HolderView holder = null;
			if(convertView == null){
				convertView = LayoutInflater.from(mContext).inflate(R.layout.taskdiscuss_item, null);
				holder = new HolderView();
				holder.contentView =(TextView) convertView.findViewById(R.id.taskdiscuss_item_text_content);
				holder.nameTextView =(TextView) convertView.findViewById(R.id.taskdiscuss_item_text_name);
				holder.timeTextView =(TextView) convertView.findViewById(R.id.taskdiscuss_item_text_time);
				convertView.setTag(holder);
			}
			else{
				holder = (HolderView) convertView.getTag();
			}
			
			if(null==mList||position>mList.size()){
				return convertView;
			}
			TaskDiscuss task = mList.get(position);
			if(task!=null){
				holder.contentView.setText(TextHelper.getFliteStr(task.discussMessage));
				holder.nameTextView.setText(TextHelper.getFliteStr(task.operatorName));
				holder.timeTextView.setText(TextHelper.getFliteStr(task.discussDate));
			}
			
			return convertView;
		}
	}